import java.util.ArrayList;


public class Bank {
	public String name, address, zipcode, city;
	public ArrayList<Customer> customers;
	
	public Bank(String name, String address, String zipcode, String city) {
		this.name = name;
		this.address = address;
		this.zipcode = zipcode;
		this.city = city;
		customers = new ArrayList<Customer>();
	}
	
	public Customer createCustomer(String name, String ssn, String address, String zipcode, String city) {
		Customer c = new Customer(name, ssn, address, zipcode, city);
		customers.add(c);
		return c;
	}
	
	public boolean addInterestToAllCustomers() {
		int index = 0; 
		while(index < customers.size() ) {
			for(Customer c : customers) {
				for(Account a : c.getAccounts()) {
					if(a.addInterest()) {
						a.addInterest(); 
						index++;
					} else {
						return false;
					}
				}
			}
		}
		return true;
	}
	
	
	public boolean setInterestForCustomersAccount(String ssn, int id, double interest) {
		Account a = findCustomer(ssn).findAccount(id);
		if(a != null) {
			a.setInterest(interest);
			return true;
		} else {
			return false;
		}
	}
	
	public Customer findCustomer(String ssn) {
		int index = 0;
		boolean found = false;
		while(index < customers.size() && !found == true) {
			if(customers.get(index).getSsn() == ssn) {
				found = true;
				return customers.get(index); 
				}
			index++;
			}
		if(found == false) {
			}
		return null;
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public ArrayList<Customer> getCustomers() {
		return customers;
	}

	public void setCustomers(ArrayList<Customer> customers) {
		this.customers = customers;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	
	

}
